import axios from "axios";
import { Message } from "element-ui";
import store from "@/store";

const fetch = axios.create({
  timeout: 5000
});
fetch.interceptors.request.use(
  config => {
    config.headers["token"] = store.getters.token;
    return config;
  },
  error => {
    console.log(error);
    Promise.reject(error);
  }
);
fetch.interceptors.response.use(
  response => response,
  error => {
    console.log("err" + error);
    Message({
      message: error.message,
      type: "error"
    });
    return Promise.reject(error);
  }
);
export default fetch;
